import scanpy as sc, anndata as ad, numpy as np, pandas as pd, seaborn as sns
from scipy import sparse
from anndata import AnnData
from matplotlib import pylab
import warnings
import scanpy.external as sce
import yaml
import matplotlib as plt
import os
import scvelo as scv
warnings.filterwarnings('ignore')
sc.settings.verbosity = 3 # verbosity: errors (0), warnings (1), info (2), hints (3)
sc.logging.print_header()
with open("../data/resources/rcParams.yaml") as f:
rcParamsDict = yaml.full_load(f)
for k in rcParamsDict["rcParams"]:
print("{} {}".format(k,rcParamsDict["rcParams"][k]))
plt.rcParams[k] = rcParamsDict["rcParams"][k]
for k1 in set(list(rcParamsDict)).difference(set(["rcParams"])):
print("{} {}".format(k1,rcParamsDict[k1]))
scanpy==1.8.0 anndata==0.8.0 umap==0.4.6 numpy==1.22.2 scipy==1.6.2 pandas==1.2.3 scikit-learn==0.24.1 statsmodels==0.13.5 python-igraph==0.9.1 louvain==0.7.0 leidenalg==0.8.3 figure.dpi 80 savefig.dpi 500 figure.figsize [10, 10] axes.facecolor white dotSize 20
outdir = "../data/output"
with open("../data/resources/iPSC_lines_map.yaml", 'r') as f:
iPSC_lines_map = yaml.load(f, Loader=yaml.FullLoader)["lines"]
PoliudakisDSpath = "../data/resources/Poliudakis.h5ad"
PoliudakisAdata=sc.read_h5ad(PoliudakisDSpath )
sc.pl.umap(PoliudakisAdata, color="Cluster", size = 10,add_outline=True, outline_width=(0.2, 0.05), vmin='p2',vmax='p98',wspace=.4, frameon=False, save="poliudakis", legend_fontsize = "xx-large")
WARNING: saving figure to file figures/umappoliudakis.pdf
adataBU = sc.read_h5ad(outdir+"/adatas/ClusterAnnotated_Base_filt.h5ad")
adata = adataBU.copy()
PoliudakisAdata=sc.read_h5ad(PoliudakisDSpath )
PoliudakisAdata.var
adataIngestion = adata.copy()
#sc.pp.regress_out(adataIngestion, ["total_counts","pct_counts_mt"])
var_names = PoliudakisAdata.var_names.intersection(adataIngestion.var_names)
adataIngestion = adataIngestion[:, var_names].copy()
PoliudakisAdata = PoliudakisAdata[:, var_names].copy()
sc.tl.ingest(adataIngestion, PoliudakisAdata, obs='Cluster')
adataBU.obs["PoliudakisIngestedAnno"] = adataIngestion.obs.loc[adataBU.obs_names,"Cluster"]
del PoliudakisAdata
sc.pl.draw_graph(adataBU, size = 10, ncols=1, add_outline=True, color=["PoliudakisIngestedAnno"], wspace=.4)
running ingest
finished (0:00:16)
for g in adataBU.obs["PoliudakisIngestedAnno"].unique():
sc.pl.draw_graph(adataBU, groups=g, color="PoliudakisIngestedAnno", size = 10,
add_outline = True,outline_width=(0.4, 0.05),vmin="p1",vmax="p99", frameon=False, ncols=2,save="ingested."+g+".svg", na_color="#F5F5F5")
WARNING: saving figure to file figures/draw_graph_faingested.ExN.svg
WARNING: saving figure to file figures/draw_graph_faingested.InCGE.svg
WARNING: saving figure to file figures/draw_graph_faingested.OPC.svg
WARNING: saving figure to file figures/draw_graph_faingested.ExM.svg
WARNING: saving figure to file figures/draw_graph_faingested.oRG.svg
WARNING: saving figure to file figures/draw_graph_faingested.PgS.svg
WARNING: saving figure to file figures/draw_graph_faingested.IP.svg
WARNING: saving figure to file figures/draw_graph_faingested.vRG.svg
WARNING: saving figure to file figures/draw_graph_faingested.InMGE.svg
WARNING: saving figure to file figures/draw_graph_faingested.PgG2M.svg
WARNING: saving figure to file figures/draw_graph_faingested.ExDp1.svg
WARNING: saving figure to file figures/draw_graph_faingested.Mic.svg
WARNING: saving figure to file figures/draw_graph_faingested.ExM-U.svg
WARNING: saving figure to file figures/draw_graph_faingested.End.svg
WARNING: saving figure to file figures/draw_graph_faingested.Per.svg
WARNING: saving figure to file figures/draw_graph_faingested.ExDp2.svg
atl100 = adataBU.obs["PoliudakisIngestedAnno"].value_counts()[adataBU.obs["PoliudakisIngestedAnno"].value_counts() > 100].index.tolist()
adataBUSS = adataBU[adataBU.obs["PoliudakisIngestedAnno"].isin(atl100)]
import holoviews as hv
obsTupleToMap = ("leidenAnnotated","PoliudakisIngestedAnno")
SankeyDF=adataBUSS.obs[list(obsTupleToMap)]
SankeyDF.columns = ["leidenAnnotated","PoliudakisIngestedAnno"]
SankeyDF = SankeyDF.groupby(['leidenAnnotated','PoliudakisIngestedAnno']).size().reset_index().rename(columns={0:'count'})
SankeyDF=SankeyDF[SankeyDF["count"] != 0]
hv.extension('bokeh')
sankey1 = hv.Sankey(SankeyDF, kdims=["leidenAnnotated", "PoliudakisIngestedAnno"], vdims="count")
sankey1.opts(cmap='Colorblind',label_position='outer',
edge_color='leidenAnnotated', edge_line_width=0,
node_alpha=1.0, node_width=40, node_sort=True,
width=1100, height=700, bgcolor="white")
adataBU.obs["PoliudakisIngestedAnno_Projection"] = adataBU.obs["PoliudakisIngestedAnno"]
sc.pl.draw_graph(adataBU, size = 10, ncols=2, add_outline=True, color=["leidenAnnotated","PoliudakisIngestedAnno_Projection"], wspace=.6, save="ingested.pdf", frameon=False)
WARNING: saving figure to file figures/draw_graph_faingested.pdf
sc.pl.draw_graph(adata, color="cellID_newName", size = 10,
add_outline = True,outline_width=(0.2, 0.05),vmin="p1",vmax="p99", frameon=False, ncols=2)